package com.leo.sentinel;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

public class MyProducer {
    public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("producer_grp_13_01");
        producer.setNamesrvAddr("localhost:9876");
        producer.start();

        Message message;

        for (int i = 0; i < 1000; i++) {
            message = new Message("tp_demo_13", ("hello world - " + i).getBytes());
            //message.putUserProperty();
            //message.setKeys();

            producer.send(message);
        }
        producer.shutdown();
    }
}